package com.nomito.minimito.controller.front;

import com.nomito.minimito.common.utils.R;
import com.nomito.minimito.entity.AdBannerEntity;
import com.nomito.minimito.entity.SqTagEntity;
import com.nomito.minimito.service.AdBannerService;
import com.nomito.minimito.service.SqTagService;
import com.nomito.minimito.service.UmAreaService;
import com.nomito.minimito.vo.RespAreaVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @author yzw
 * @date 2020/5/16
 */
@Api(tags = "首页相关接口")
@CrossOrigin
@RestController
@RequestMapping("/front")
public class FIndexController {

    @Autowired
    SqTagService tagService;
    @Autowired
    AdBannerService bannerService;
    @Autowired
    UmAreaService umAreaService;


    /**
     * 首页查询标签方法
     */
    @ApiOperation(value = "首页查询所有的标签")
    @GetMapping("/getTag")
    public R getTag(){
        List<SqTagEntity> tagEntityList = tagService.list(null);
        return R.ok().setData(tagEntityList);
    }

    /**
     *轮播图查询
     */
    @ApiOperation(value = "轮播查询")
    @GetMapping("/getBanner")
    public R getBanner(){
        List<AdBannerEntity> adBannerEntityList = bannerService.list(null);
        return R.ok().put("data",adBannerEntityList);
    }
    /**
     * 获取地址集合
     */
    @ApiOperation(value = "获取地址集合")
    @GetMapping("/getAddressList")
    public R getAddressList(){
        List<RespAreaVo> vo =umAreaService.getAddressList();
        return R.ok().setData(vo);
    }

}
